package scene.gameObject 
{
	import log.Log;
	import resource.ImageResource;
	import scene.map.Map;
	import scene.scene.SceneData;
	/**
	 * ...
	 * @author carlor
	 */
	public class CharObject extends ActivateObject
	{
		
		public function CharObject(map: Map, owner: SceneData, data: Object, settingData: Object) 
		{
			super(map, owner, data, settingData);
		}
		
		override public function dispose(): void
		{
			super.dispose();
		}
		
		override protected function init(settingData: Object): void
		{
			//_actionData = CX.CharConfig["Job-" + _basicData.job];
			_actionData = settingData;
			super.init(settingData);
		}
		
		override protected function loadImages(): void
		{
			for (var i: int = 0; i < _imageArray.length; i++) {
				Engine.resourceManager.unloadResource(_imageArray[i].fileName, ImageResource);
			}
			_imageArray = [];
			for (i = 0; i < ActionConst.ACTIONIMAGES.length; i++) {
				Engine.resourceManager.loadResource(getResourceName(ActionConst.ACTIONIMAGES[i]), ImageResource, onResourceLoaded, onResourceLoadFailed);
			}
		}
		
		protected function getResourceName(action: int): String
		{
			return Engine.settingPath + "char\\" + ActionConst.JOBNAME[_basicData.job - 1] + "\\F1\\" + ActionConst.ACTIONNAME[action - 1] + ".png";	
		}
		
		override protected function onResourceLoadFailed(r: ImageResource): void
		{
			super.onResourceLoadFailed(r);
			Log.formatErrorLog("CharObject.onLoadFailed job=%% file=%%", [_basicData.job, r.fileName]);			
		}
		
	}

}